#pragma once
// MESSAGE MAVLINK_COMM_CTRL PACKING

#define MAVLINK_MSG_ID_MAVLINK_COMM_CTRL 172

MAVPACKED(
typedef struct __mavlink_mavlink_comm_ctrl_t {
 uint8_t comm_sw; /*<  comm switch.*/
 uint8_t res1; /*<  res1*/
 uint8_t res2; /*<  res2*/
}) mavlink_mavlink_comm_ctrl_t;

#define MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN 3
#define MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_MIN_LEN 3
#define MAVLINK_MSG_ID_172_LEN 3
#define MAVLINK_MSG_ID_172_MIN_LEN 3

#define MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_CRC 74
#define MAVLINK_MSG_ID_172_CRC 74



#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_MAVLINK_COMM_CTRL { \
    172, \
    "MAVLINK_COMM_CTRL", \
    3, \
    {  { "comm_sw", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mavlink_comm_ctrl_t, comm_sw) }, \
         { "res1", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mavlink_comm_ctrl_t, res1) }, \
         { "res2", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mavlink_comm_ctrl_t, res2) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_MAVLINK_COMM_CTRL { \
    "MAVLINK_COMM_CTRL", \
    3, \
    {  { "comm_sw", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mavlink_comm_ctrl_t, comm_sw) }, \
         { "res1", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mavlink_comm_ctrl_t, res1) }, \
         { "res2", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mavlink_comm_ctrl_t, res2) }, \
         } \
}
#endif

/**
 * @brief Pack a mavlink_comm_ctrl message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param comm_sw  comm switch.
 * @param res1  res1
 * @param res2  res2
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_mavlink_comm_ctrl_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               uint8_t comm_sw, uint8_t res1, uint8_t res2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN];
    _mav_put_uint8_t(buf, 0, comm_sw);
    _mav_put_uint8_t(buf, 1, res1);
    _mav_put_uint8_t(buf, 2, res2);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN);
#else
    mavlink_mavlink_comm_ctrl_t packet;
    packet.comm_sw = comm_sw;
    packet.res1 = res1;
    packet.res2 = res2;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_MAVLINK_COMM_CTRL;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_MIN_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_CRC);
}

/**
 * @brief Pack a mavlink_comm_ctrl message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param comm_sw  comm switch.
 * @param res1  res1
 * @param res2  res2
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_mavlink_comm_ctrl_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   uint8_t comm_sw,uint8_t res1,uint8_t res2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN];
    _mav_put_uint8_t(buf, 0, comm_sw);
    _mav_put_uint8_t(buf, 1, res1);
    _mav_put_uint8_t(buf, 2, res2);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN);
#else
    mavlink_mavlink_comm_ctrl_t packet;
    packet.comm_sw = comm_sw;
    packet.res1 = res1;
    packet.res2 = res2;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_MAVLINK_COMM_CTRL;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_MIN_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_CRC);
}

/**
 * @brief Encode a mavlink_comm_ctrl struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param mavlink_comm_ctrl C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_mavlink_comm_ctrl_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mavlink_comm_ctrl_t* mavlink_comm_ctrl)
{
    return mavlink_msg_mavlink_comm_ctrl_pack(system_id, component_id, msg, mavlink_comm_ctrl->comm_sw, mavlink_comm_ctrl->res1, mavlink_comm_ctrl->res2);
}

/**
 * @brief Encode a mavlink_comm_ctrl struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param mavlink_comm_ctrl C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_mavlink_comm_ctrl_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mavlink_comm_ctrl_t* mavlink_comm_ctrl)
{
    return mavlink_msg_mavlink_comm_ctrl_pack_chan(system_id, component_id, chan, msg, mavlink_comm_ctrl->comm_sw, mavlink_comm_ctrl->res1, mavlink_comm_ctrl->res2);
}

/**
 * @brief Send a mavlink_comm_ctrl message
 * @param chan MAVLink channel to send the message
 *
 * @param comm_sw  comm switch.
 * @param res1  res1
 * @param res2  res2
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_mavlink_comm_ctrl_send(mavlink_channel_t chan, uint8_t comm_sw, uint8_t res1, uint8_t res2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN];
    _mav_put_uint8_t(buf, 0, comm_sw);
    _mav_put_uint8_t(buf, 1, res1);
    _mav_put_uint8_t(buf, 2, res2);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL, buf, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_MIN_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_CRC);
#else
    mavlink_mavlink_comm_ctrl_t packet;
    packet.comm_sw = comm_sw;
    packet.res1 = res1;
    packet.res2 = res2;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL, (const char *)&packet, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_MIN_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_CRC);
#endif
}

/**
 * @brief Send a mavlink_comm_ctrl message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_mavlink_comm_ctrl_send_struct(mavlink_channel_t chan, const mavlink_mavlink_comm_ctrl_t* mavlink_comm_ctrl)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_mavlink_comm_ctrl_send(chan, mavlink_comm_ctrl->comm_sw, mavlink_comm_ctrl->res1, mavlink_comm_ctrl->res2);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL, (const char *)mavlink_comm_ctrl, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_MIN_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_CRC);
#endif
}

#if MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_mavlink_comm_ctrl_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  uint8_t comm_sw, uint8_t res1, uint8_t res2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;
    _mav_put_uint8_t(buf, 0, comm_sw);
    _mav_put_uint8_t(buf, 1, res1);
    _mav_put_uint8_t(buf, 2, res2);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL, buf, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_MIN_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_CRC);
#else
    mavlink_mavlink_comm_ctrl_t *packet = (mavlink_mavlink_comm_ctrl_t *)msgbuf;
    packet->comm_sw = comm_sw;
    packet->res1 = res1;
    packet->res2 = res2;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL, (const char *)packet, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_MIN_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_CRC);
#endif
}
#endif

#endif

// MESSAGE MAVLINK_COMM_CTRL UNPACKING


/**
 * @brief Get field comm_sw from mavlink_comm_ctrl message
 *
 * @return  comm switch.
 */
static inline uint8_t mavlink_msg_mavlink_comm_ctrl_get_comm_sw(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  0);
}

/**
 * @brief Get field res1 from mavlink_comm_ctrl message
 *
 * @return  res1
 */
static inline uint8_t mavlink_msg_mavlink_comm_ctrl_get_res1(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  1);
}

/**
 * @brief Get field res2 from mavlink_comm_ctrl message
 *
 * @return  res2
 */
static inline uint8_t mavlink_msg_mavlink_comm_ctrl_get_res2(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  2);
}

/**
 * @brief Decode a mavlink_comm_ctrl message into a struct
 *
 * @param msg The message to decode
 * @param mavlink_comm_ctrl C-struct to decode the message contents into
 */
static inline void mavlink_msg_mavlink_comm_ctrl_decode(const mavlink_message_t* msg, mavlink_mavlink_comm_ctrl_t* mavlink_comm_ctrl)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_comm_ctrl->comm_sw = mavlink_msg_mavlink_comm_ctrl_get_comm_sw(msg);
    mavlink_comm_ctrl->res1 = mavlink_msg_mavlink_comm_ctrl_get_res1(msg);
    mavlink_comm_ctrl->res2 = mavlink_msg_mavlink_comm_ctrl_get_res2(msg);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN? msg->len : MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN;
        memset(mavlink_comm_ctrl, 0, MAVLINK_MSG_ID_MAVLINK_COMM_CTRL_LEN);
    memcpy(mavlink_comm_ctrl, _MAV_PAYLOAD(msg), len);
#endif
}
